﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace IcarusProject.Icarus
{
    public class GameController
    {
        #region Attributs
        private KeyboardState _prevKState;
        private KeyboardState _curKState;
        private static GameController _singleton;
        #endregion

        #region Constructeur
        private GameController()
        {
            _prevKState = Keyboard.GetState();
            _curKState = Keyboard.GetState();
        }
        #endregion

        #region Proprietes
        #endregion

        #region Methodes
        public static GameController GetSingleton()
        {
            if (_singleton == null)
                _singleton = new GameController();
            return _singleton;
        }

        public void Update(GameTime game)
        {
            _prevKState = _curKState;
            _curKState = Keyboard.GetState();
        }

        public bool IsKeyPressed(Keys k)
        {
            return _prevKState.IsKeyDown(k) && _curKState.IsKeyUp(k);
        }

        public bool IsKeyDown(Keys k)
        {
            return _curKState.IsKeyDown(k);
        }
        #endregion
    }
}
